/**
 * @param {string} street
 * @return {number}
 */
 var minimumBuckets = function(street) {
  const n = street.length
  const arr = []
  let cnt = 0
  for(let i = 0; i<n; i++){
    if(street[i] === 'H') arr.push(i)
    else cnt++
  }
  if(arr.length === 0) return 0
  if(cnt === 0) return -1
  let ans = arr.length
  for(let x of arr){
    let flag = false
    if(x > 0 && street[x-1] === '.') flag = true
    if(x < street.length-1 && street[x+1] === '.') flag = true
    if(!flag) return -1
  }
  let pre = -1
  for(let i = 1; i<arr.length; i++){
    if(arr[i] - arr[i-1] === 2 && pre !== i-1){
      pre = i
      ans--
    }
  }
  return ans
};